package org.swxjava;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WebContextFactory {
	
	public static WebContext get() {
		if (builder == null) {
			return null;
		}
		return builder.get();
	}

	public static void setWebContextBuilder(WebContextBuilder builder) {
		WebContextFactory.builder = builder;
	}

	/**
	 * The WebContextBuilder from which we will get WebContext objects
	 */
	private static WebContextBuilder builder;

	/**
	 * Class to enable us to access servlet parameters.
	 */
	public interface WebContextBuilder {
		WebContext get();
		void set(HttpServletRequest request, HttpServletResponse response,
				ServletConfig config, ServletContext context,
				Container container);
		void unset();
	}
}
